package cn.wolfcode.crm.service.impl;

import cn.wolfcode.crm.domain.Order;
import cn.wolfcode.crm.mapper.OrderMapper;
import cn.wolfcode.crm.query.ProductQueryObejct;
import cn.wolfcode.crm.service.IOrderService;
import cn.wolfcode.crm.util.PageResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class OrderServiceImpl implements IOrderService {

    @Autowired
    private OrderMapper orderMapper;

    @Override
    public Order selectByPrimaryKey(Long id) {
        return orderMapper.selectByPrimaryKey(id);
    }

    @Override
    public List<Order> selectAll() {
        return orderMapper.selectAll();
    }

    @Override
    public PageResult query(ProductQueryObejct qo) {

        int total = orderMapper.queryForCount(qo);
        if (total == 0) {
            return new PageResult();
        }

        List list = orderMapper.queryForList(qo);
        return new PageResult(total, list);

    }

    /*查询列表的数据*/
    @Override
    public List queryForList(ProductQueryObejct qo) {
        List<Order> rows = orderMapper.queryForList(qo);
        return rows;

    }
}
